package com.star.sync.elasticsearch.common;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 映射
 *
 * @author liu
 */

@PropertySource("classpath:type_mapping.properties")
@ConfigurationProperties
@Component
@Data
public class MysqlEsTypeMapping {

    private Map<String, String> mapping_map;

    public String mapping(String fieldType){
       String[] fieldTypes= fieldType.split("\\.");
        fieldType=fieldTypes[fieldTypes.length-1];
        if(mapping_map.get(fieldType)!=null){
            return mapping_map.get(fieldType);
        }
        return "object";
    }

}
